package com.muyu.danmo.service.impl;


import com.muyu.common.core.domain.Result;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.danmo.domain.DanmoUserFollowers;
import com.muyu.danmo.mapper.DanmoUserFollowersMapper;
import com.muyu.danmo.service.IDanmoUserFollowersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 粉丝Service业务层处理
 *
 * @author yangle
 * @date 2024-11-15
 */
@Service
public class DanmoUserFollowersServiceImpl implements IDanmoUserFollowersService {
    @Autowired
    private DanmoUserFollowersMapper danmoUserFollowersMapper;

    /**
     * 查询粉丝
     *
     * @param followerId 粉丝主键
     * @return 粉丝
     */
    @Override
    public DanmoUserFollowers selectDanmoUserFollowersByFollowerId(Long followerId) {
        return danmoUserFollowersMapper.selectDanmoUserFollowersByFollowerId(followerId);
    }

    /**
     * 查询粉丝列表
     *
     * @param danmoUserFollowers 粉丝
     * @return 粉丝
     */
    @Override
    public List<DanmoUserFollowers> selectDanmoUserFollowersList(DanmoUserFollowers danmoUserFollowers) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        danmoUserFollowers = new DanmoUserFollowers();
        danmoUserFollowers.setFolloweeId(loginUser.getUserid());
        return danmoUserFollowersMapper.selectDanmoUserFollowersList(danmoUserFollowers);
    }

    /**
     * 新增粉丝
     *
     * @param danmoUserFollowers 粉丝
     * @return 结果
     */
    @Override
    public void insertDanmoUserFollowers(DanmoUserFollowers danmoUserFollowers) {
        danmoUserFollowersMapper.insertDanmoUserFollowers(danmoUserFollowers);
    }

    /**
     * 修改粉丝
     *
     * @param danmoUserFollowers 粉丝
     * @return 结果
     */
    @Override
    public Result updateDanmoUserFollowers(DanmoUserFollowers danmoUserFollowers) {
        return danmoUserFollowersMapper.updateDanmoUserFollowers(danmoUserFollowers);
    }

    /**
     * 批量删除粉丝
     *
     * @param followerIds 需要删除的粉丝主键
     * @return 结果
     */
    @Override
    public Result deleteDanmoUserFollowersByFollowerIds(Long[] followerIds) {
        return danmoUserFollowersMapper.deleteDanmoUserFollowersByFollowerIds(followerIds);
    }

    /**
     * 删除粉丝信息
     *
     * @param followerId 粉丝主键
     * @return 结果
     */
    @Override
    public Result deleteDanmoUserFollowersByFollowerId(Long followerId) {
        return danmoUserFollowersMapper.deleteDanmoUserFollowersByFollowerId(followerId);
    }
}
